using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using BA.DAL;
using Microsoft.VisualBasic;

namespace BlazeApps.Library.Forum
{
    public class ForumList : Base
    {
        private BA.DAL.DBUtility DAL = new BA.DAL.DBUtility();
        private Procedures Procs = new Procedures();

        public DataTable GetForums()
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            return DAL.GetDataTable(Procs.ListForumForum.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }

        public DataTable GetForums(Guid CategoryID)
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("CategoryID", CategoryID);

            return DAL.GetDataTable(Procs.ListForumForumByCategoryID.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }

        public DataTable GetForumModerators(Guid ForumID)
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@ForumID", ForumID);

            return DAL.GetDataTable(Procs.ListForumModeratorsByForumID.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }

        public DataTable GetForumPendingPostsByUser(Guid UserID)
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@UserID", UserID);

            return DAL.GetDataTable(Procs.ListPendingForumPostsByUserID.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }

        public DataTable GetForumPendingPosts(Guid ModeratorID)
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@ModeratorID", ModeratorID);

            return DAL.GetDataTable(Procs.ListPendingForumPostsByModeratorID.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }

        public Int32 GetForumPendingPostsCount(Guid ModeratorID)
        {
            DataRow row;
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@ModeratorID", ModeratorID);

            row = DAL.GetDataTable(Procs.ListPendingForumPostsCountByModeratorID.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open).Rows[0];

            return Convert.ToInt32(row["pendingpostscount"]);
        }

        public DataTable GetBreadCrumbLinks(Guid ForumID)
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@ForumID", ForumID);

            return DAL.GetDataTable(Procs.ListLinkDataForForumByForumID.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }

        public DataTable GetForumSelectionList()
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            return DAL.GetDataTable(Procs.ListForumSelection.ToString().Trim(), System.Data.CommandType.Text, System.Data.ConnectionState.Open);
        }
    }
}
